/*********按|截取数据*************/
function analysisMyValue(json, jsonString) {
  try {
    var str = "|" + jsonString + "|:";
    json = json.split(str);
    json = json[1];
    json = json.split("'");
    var resp = json[1];
    return resp;
  } catch (e) {
    return "";
  }
}

/*********湖北车籍地转换*************/
function changeVehicleLocus() {
  return [
    { value: "420000", label: "湖北省" },
    { value: "420100", label: "武汉市" },
    { value: "420200", label: "黄石市" },
    { value: "420300", label: "十堰市" },
    { value: "420500", label: "宜昌市" },
    { value: "420600", label: "襄阳市" },
    { value: "420700", label: "鄂州市" },
    { value: "420800", label: "荆门市" },
    { value: "420900", label: "孝感市" },
    { value: "421000", label: "荆州市" },
    { value: "421100", label: "黄冈市" },
    { value: "421200", label: "咸宁市" },
    { value: "421300", label: "随州市" },
    { value: "422800", label: "恩施州" },
    { value: "429004", label: "仙桃市" },
    { value: "429005", label: "潜江市" },
    { value: "429006", label: "天门市" },
    { value: "429021", label: "神农架林区" },
  ];
}

/*********省份名称转省份编码*************/
function pronameChangecode(proname) {
  var procode;
  if (proname == "全国") {
    procode = "";
  }
  if (proname == "北京市") {
    procode = "110000";
  }
  if (proname == "天津市") {
    procode = "120000";
  }
  if (proname == "河北省") {
    procode = "130000";
  }
  if (proname == "山西省") {
    procode = "140000";
  }
  if (proname == "内蒙古自治区") {
    procode = "150000";
  }
  if (proname == "辽宁省") {
    procode = "210000";
  }
  if (proname == "吉林省") {
    procode = "220000";
  }
  if (proname == "黑龙江省") {
    procode = "230000";
  }
  if (proname == "上海市") {
    procode = "310000";
  }
  if (proname == "江苏省") {
    procode = "320000";
  }
  if (proname == "浙江省") {
    procode = "330000";
  }
  if (proname == "安徽省") {
    procode = "340000";
  }
  if (proname == "福建省") {
    procode = "350000";
  }
  if (proname == "江西省") {
    procode = "360000";
  }
  if (proname == "山东省") {
    procode = "370000";
  }
  if (proname == "河南省") {
    procode = "410000";
  }
  if (proname == "湖北省") {
    procode = "420000";
  }
  if (proname == "湖南省") {
    procode = "430000";
  }
  if (proname == "广东省") {
    procode = "440000";
  }
  if (proname == "广西壮族自治区") {
    procode = "450000";
  }
  if (proname == "海南省") {
    procode = "460000";
  }
  if (proname == "重庆市") {
    procode = "500000";
  }
  if (proname == "四川省") {
    procode = "510000";
  }
  if (proname == "贵州省") {
    procode = "520000";
  }
  if (proname == "云南省") {
    procode = "530000";
  }
  if (proname == "西藏自治区") {
    procode = "540000";
  }
  if (proname == "陕西省") {
    procode = "610000";
  }
  if (proname == "甘肃省") {
    procode = "620000";
  }
  if (proname == "青海省") {
    procode = "630000";
  }
  if (proname == "宁夏回族自治区") {
    procode = "640000";
  }
  if (proname == "新疆维吾尔自治区") {
    procode = "650000";
  }
  return procode;
}

/*********省份编码转省份名称*************/
function procodeChangename(procode) {
  var proname;
  if (procode == "") {
    proname = "全国";
  }
  if (procode == "110000") {
    proname = "北京市";
  }
  if (procode == "120000") {
    proname = "天津市";
  }
  if (procode == "130000") {
    proname = "河北省";
  }
  if (procode == "140000") {
    proname = "山西省";
  }
  if (procode == "150000") {
    proname = "内蒙古自治区";
  }
  if (procode == "210000") {
    proname = "辽宁省";
  }
  if (procode == "220000") {
    proname = "吉林省";
  }
  if (procode == "230000") {
    proname = "黑龙江省";
  }
  if (procode == "310000") {
    proname = "上海市";
  }
  if (procode == "320000") {
    proname = "江苏省";
  }
  if (procode == "330000") {
    proname = "浙江省";
  }
  if (procode == "340000") {
    proname = "安徽省";
  }
  if (procode == "350000") {
    proname = "福建省";
  }
  if (procode == "360000") {
    proname = "江西省";
  }
  if (procode == "370000") {
    proname = "山东省";
  }
  if (procode == "410000") {
    proname = "河南省";
  }
  if (procode == "420000") {
    proname = "湖北省";
  }
  if (procode == "430000") {
    proname = "湖南省";
  }
  if (procode == "440000") {
    proname = "广东省";
  }
  if (procode == "450000") {
    proname = "广西壮族自治区";
  }
  if (procode == "460000") {
    proname = "海南省";
  }
  if (procode == "500000") {
    proname = "重庆市";
  }
  if (procode == "510000") {
    proname = "四川省";
  }
  if (procode == "520000") {
    proname = "贵州省";
  }
  if (procode == "530000") {
    proname = "云南省";
  }
  if (procode == "540000") {
    proname = "西藏自治区";
  }
  if (procode == "610000") {
    proname = "陕西省";
  }
  if (procode == "620000") {
    proname = "甘肃省";
  }
  if (procode == "630000") {
    proname = "青海省";
  }
  if (procode == "640000") {
    proname = "宁夏回族自治区";
  }
  if (procode == "650000") {
    proname = "新疆维吾尔自治区";
  }
  return proname;
}

/*********省份名称转车牌首字*************/
function pronameChangeVehi(proname) {
  var vehi;
  if (proname == "全国") {
    vehi = "";
  }
  if (proname == "北京市") {
    vehi = "京";
  }
  if (proname == "天津市") {
    vehi = "津";
  }
  if (proname == "河北省") {
    vehi = "冀";
  }
  if (proname == "山西省") {
    vehi = "晋";
  }
  if (proname == "内蒙古自治区") {
    vehi = "蒙";
  }
  if (proname == "辽宁省") {
    vehi = "辽";
  }
  if (proname == "吉林省") {
    vehi = "吉";
  }
  if (proname == "黑龙江省") {
    vehi = "黑";
  }
  if (proname == "上海市") {
    vehi = "沪";
  }
  if (proname == "江苏省") {
    vehi = "苏";
  }
  if (proname == "浙江省") {
    vehi = "浙";
  }
  if (proname == "安徽省") {
    vehi = "皖";
  }
  if (proname == "福建省") {
    vehi = "闽";
  }
  if (proname == "江西省") {
    vehi = "赣";
  }
  if (proname == "山东省") {
    vehi = "鲁";
  }
  if (proname == "河南省") {
    vehi = "豫";
  }
  if (proname == "湖北省") {
    vehi = "鄂";
  }
  if (proname == "湖南省") {
    vehi = "湘";
  }
  if (proname == "广东省") {
    vehi = "粤";
  }
  if (proname == "广西壮族自治区") {
    vehi = "桂";
  }
  if (proname == "海南省") {
    vehi = "琼";
  }
  if (proname == "重庆市") {
    vehi = "渝";
  }
  if (proname == "四川省") {
    vehi = "川";
  }
  if (proname == "贵州省") {
    vehi = "贵";
  }
  if (proname == "云南省") {
    vehi = "云";
  }
  if (proname == "西藏自治区") {
    vehi = "藏";
  }
  if (proname == "陕西省") {
    vehi = "陕";
  }
  if (proname == "甘肃省") {
    vehi = "甘";
  }
  if (proname == "青海省") {
    vehi = "青";
  }
  if (proname == "宁夏回族自治区") {
    vehi = "宁";
  }
  if (proname == "新疆维吾尔自治区") {
    vehi = "新";
  }
  return vehi;
}

/*********车牌首字转省份名称*************/
function vehiChangeProname(vehi) {
  var proname = "";
  if (vehi == "") {
    proname = "全国";
  }
  if (vehi == "京") {
    proname = "北京市";
  }
  if (vehi == "津") {
    proname = "天津市";
  }
  if (vehi == "冀") {
    proname = "河北省";
  }
  if (vehi == "晋") {
    proname = "山西省";
  }
  if (vehi == "蒙") {
    proname = "内蒙古自治区";
  }
  if (vehi == "辽") {
    proname = "辽宁省";
  }
  if (vehi == "吉") {
    proname = "吉林省";
  }
  if (vehi == "黑") {
    proname = "黑龙江省";
  }
  if (vehi == "沪") {
    proname = "上海市";
  }
  if (vehi == "苏") {
    proname = "江苏省";
  }
  if (vehi == "浙") {
    proname = "浙江省";
  }
  if (vehi == "皖") {
    proname = "安徽省";
  }
  if (vehi == "闽") {
    proname = "福建省";
  }
  if (vehi == "赣") {
    proname = "江西省";
  }
  if (vehi == "鲁") {
    proname = "山东省";
  }
  if (vehi == "豫") {
    proname = "河南省";
  }
  if (vehi == "鄂") {
    proname = "湖北省";
  }
  if (vehi == "湘") {
    proname = "湖南省";
  }
  if (vehi == "粤") {
    proname = "广东省";
  }
  if (vehi == "桂") {
    proname = "广西壮族自治区";
  }
  if (vehi == "琼") {
    proname = "海南省";
  }
  if (vehi == "渝") {
    proname = "重庆市";
  }
  if (vehi == "川") {
    proname = "四川省";
  }
  if (vehi == "贵") {
    proname = "贵州省";
  }
  if (vehi == "云") {
    proname = "云南省";
  }
  if (vehi == "藏") {
    proname = "西藏自治区";
  }
  if (vehi == "陕") {
    proname = "陕西省";
  }
  if (vehi == "甘") {
    proname = "甘肃省";
  }
  if (vehi == "青") {
    proname = "青海省";
  }
  if (vehi == "宁") {
    proname = "宁夏回族自治区";
  }
  if (vehi == "新") {
    proname = "新疆维吾尔自治区";
  }
  return proname;
}

/*************车辆营运状态***************/
function changeOperstate(code) {
  var oper = "";
  if (code == "10") {
    oper = "营运";
  }
  if (code == "21") {
    oper = "停运";
  }
  if (code == "22") {
    oper = "挂失";
  }
  if (code == "31") {
    oper = "迁出-过户";
  }
  if (code == "32") {
    oper = "迁出-转籍";
  }
  if (code == "33") {
    oper = "报废";
  }
  if (code == "34") {
    oper = "歇业";
  }
  if (code == "80") {
    oper = "注销";
  }
  if (code == "90") {
    oper = "其他";
  }
  return oper;
}

/*************业户经营状态***************/
function changeOperowner(code) {
  var oper = "";
  if (code == "1") {
    oper = "营业";
  }
  if (code == "2") {
    oper = "停业";
  }
  if (code == "3") {
    oper = "整改";
  }
  if (code == "4") {
    oper = "停业整顿";
  }
  if (code == "5") {
    oper = "歇业";
  }
  if (code == "6") {
    oper = "注销";
  }
  if (code == "9") {
    oper = "其他";
  }
  return oper;
}

/*************车牌颜色***************/
function changePlatecolor(code) {
  var color = "";
  if (code == "1") {
    color = "蓝色";
  }
  if (code == "2") {
    color = "黄色";
  }
  if (code == "3") {
    color = "黑色";
  }
  if (code == "4") {
    color = "白色";
  }
  if (code == "5") {
    color = "绿色";
  }
  if (code == "9") {
    color = "其他";
  }
  return color;
}

/*************车牌颜色代码***************/
function changePlatecolorCode(code) {
  var color = "9";
  if (code == "蓝色") {
    color = "1";
  }
  if (code == "黄色") {
    color = "2";
  }
  if (code == "黑色") {
    color = "3";
  }
  if (code == "白色") {
    color = "4";
  }
  if (code == "绿色") {
    color = "5";
  }
  if (code == "其他") {
    color = "9";
  }
  return color;
}

/*************车辆行业类别***************/
function changeTrans(str) {
  if (str == 10) {
    return "道路旅客运输";
  }
  if (str == 20) {
    return "道路普通货物运输";
  }
  if (str == 30) {
    return "道路危险货物运输";
  }
  if (str == 40) {
    return "机动车维修";
  }
  if (str == 50) {
    return "机动车驾驶员培训(教练车)";
  }
  if (str == 61) {
    return "道路客运站";
  }
  if (str == 62) {
    return "道路货运站";
  }
  if (str == 70) {
    return "国际道路运输";
  }
  if (str == 80) {
    return "公交运输";
  }
  if (str == 90) {
    return "出租运输";
  }
  if (str == 93) {
    return "客运网约出租运输";
  }
  if (str == 100) {
    return "汽车租赁";
  }
  if (str == 110) {
    return "机动车综合性能检测";
  }
  if (str == 120) {
    return "道路货运辅助";
  }

  if (str == "道路旅客运输") {
    return 10;
  }
  if (str == "道路普通货物运输") {
    return 20;
  }
  if (str == "道路危险货物运输") {
    return 30;
  }
  if (str == "机动车维修") {
    return 40;
  }
  if (str == "机动车驾驶员培训(教练车)") {
    return 50;
  }
  if (str == "道路客运站") {
    return 61;
  }
  if (str == "道路货运站") {
    return 62;
  }
  if (str == "国际道路运输") {
    return 70;
  }
  if (str == "公交运输") {
    return 80;
  }
  if (str == "出租运输") {
    return 90;
  }
  if (str == "客运网约出租运输") {
    return 93;
  }
  if (str == "汽车租赁") {
    return 100;
  }
  if (str == "机动车综合性能检测") {
    return 110;
  }
  if (str == "道路货运辅助") {
    return 120;
  }
}

/*************车辆类型***************/
function changeVehType(str) {
  var vehType = "";
  if (str == 12) {
    vehType = "中型客车";
  }
  if (str == 13) {
    vehType = "小型客车";
  }
  if (str == 20) {
    vehType = "普通货车";
  }
  if (str == 21) {
    vehType = "大型普通客车";
  }
  if (str == 22) {
    vehType = "中型普通货车";
  }
  if (str == 23) {
    vehType = "小型普通货车";
  }
  if (str == 30) {
    vehType = "专用运输车";
  }
  if (str == 31) {
    vehType = "集装箱车";
  }
  if (str == 32) {
    vehType = "大件运输车";
  }
  if (str == 33) {
    vehType = "保湿冷藏车";
  }
  if (str == 34) {
    vehType = "商品车运输专用车辆";
  }
  if (str == 35) {
    vehType = "罐车";
  }
  if (str == 36) {
    vehType = "牵引车";
  }
  if (str == 37) {
    vehType = "挂车";
  }
  if (str == 38) {
    vehType = "平板车";
  }
  if (str == 39) {
    vehType = "其他专用车";
  }
  if (str == 40) {
    vehType = "危险品运输车";
  }
  if (str == 50) {
    vehType = "农用车";
  }
  if (str == 60) {
    vehType = "拖拉机";
  }
  if (str == 90) {
    vehType = "其他车辆";
  }
  if (str == 12) {
    vehType = "中型客车";
  }
  if (str == 13) {
    vehType = "小型客车";
  }
  if (str == 20) {
    vehType = "普通货车";
  }
  if (str == 21) {
    vehType = "大型普通客车";
  }
  if (str == 22) {
    vehType = "中型普通货车";
  }
  if (str == 23) {
    vehType = "小型普通货车";
  }
  if (str == 30) {
    vehType = "专用运输车";
  }
  if (str == 31) {
    vehType = "集装箱车";
  }
  if (str == 32) {
    vehType = "大件运输车";
  }
  if (str == 33) {
    vehType = "保湿冷藏车";
  }
  if (str == 34) {
    vehType = "商品车运输专用车辆";
  }
  if (str == 35) {
    vehType = "罐车";
  }
  if (str == 36) {
    vehType = "牵引车";
  }
  if (str == 37) {
    vehType = "挂车";
  }
  if (str == 38) {
    vehType = "平板车";
  }
  if (str == 39) {
    vehType = "其他专用车";
  }
  if (str == 40) {
    vehType = "危险品运输车";
  }
  if (str == 50) {
    vehType = "农用车";
  }
  if (str == 60) {
    vehType = "拖拉机";
  }
  if (str == 90) {
    vehType = "其他车辆";
  }
  return vehType;
}

/*************燃料类型***************/
function getFueltype(str) {
  if (str == 1) {
    str = "汽油";
  }
  if (str == 2) {
    str = "柴油";
  }
  if (str == 3) {
    str = "天然气";
  }
  if (str == 4) {
    str = "液化气";
  }
  if (str == 5) {
    str = "电动";
  }
  if (str == 9) {
    str = "电动";
  }
  return str;
}

/*************年审、二维码解锁方式***************/
function lockmode(str) {
  if (str == 0) {
    str = "未解锁";
  }
  if (str == 1) {
    str = "已处罚";
  }
  if (str == 2) {
    str = "人工";
  }
  return str;
}

/*************是否***************/
function isEntry(str) {
  if (str == 0) {
    str = "否";
  }
  if (str == 1) {
    str = "是";
  }
  return str;
}

/*************车辆用途***************/
function vehiuse(str) {
  if (str == 1) {
    str = "经营性";
  }
  if (str == 2) {
    str = "非经营性";
  }
  return str;
}

/*************证件介质类型***************/
function certstype(str) {
  if (str == 1) {
    str = "纸质";
  }
  if (str == 2) {
    str = "电子";
  }
  if (str == 3) {
    str = "其他";
  }
  return str;
}

/*************证件状态***************/
function certstatus(str) {
  if (str == 1) {
    str = "有效";
  }
  if (str == 2) {
    str = "无效";
  }
  return str;
}

/*************业户证照类型***************/
function ownercerttype(str) {
  if (str == 1) {
    str = "道路经营许可证";
  }
  if (str == 2) {
    str = "道路辅助经营许可证";
  }
  return str;
}

/*************人员证照类型***************/
function getPracCertType(str) {
  if (str == 1) {
    str = "道路运输从业证件";
  }
  if (str == 2) {
    str = "教练员证件";
  }
  if (str == 3) {
    str = "出租车驾驶员";
  }
  return str;
}

/*************人员从业类型***************/
function getPracPersonnelType(str) {
  if (str == 1) {
    str = "普通从业人员";
  }
  if (str == 2) {
    str = "出租车驾驶员";
  }
  if (str == 3) {
    str = "教练员";
  }
  return str;
}

/*************人员资格类别***************/
function getWorkType(str) {
  var workTypeStr = "";
  if (str == "01001") {
    workTypeStr = "客运驾驶员";
  }
  if (str == "02001") {
    workTypeStr = "货运驾驶员";
  }
  if (str == "03001") {
    workTypeStr = "危货驾驶员";
  }
  if (str == "03002") {
    workTypeStr = "危货装卸员";
  }
  if (str == "03003") {
    workTypeStr = "危货押运员";
  }
  if (str == "03004") {
    workTypeStr = "危货安全员";
  }
  if (str == "03005") {
    workTypeStr = "剧毒品驾驶员";
  }
  if (str == "03006") {
    workTypeStr = "剧毒品装卸员";
  }
  if (str == "03007") {
    workTypeStr = "剧毒品押运员";
  }
  if (str == "03008") {
    workTypeStr = "剧毒品安全员";
  }
  if (str == "03009") {
    workTypeStr = "爆炸品驾驶员";
  }
  if (str == "03010") {
    workTypeStr = "爆炸品装卸员";
  }
  if (str == "03011") {
    workTypeStr = "爆炸品押运员";
  }
  if (str == "03012") {
    workTypeStr = "爆炸品安全员";
  }
  if (str == "03013") {
    workTypeStr = "放射品驾驶员";
  }
  if (str == "03014") {
    workTypeStr = "放射品装卸员";
  }
  if (str == "03015") {
    workTypeStr = "放射品押运员";
  }
  if (str == "03016") {
    workTypeStr = "放射品安全员";
  }
  if (str == "04001") {
    workTypeStr = "维修•技术负责";
  }
  if (str == "04002") {
    workTypeStr = "维修•质检";
  }
  if (str == "04003") {
    workTypeStr = "维修•机修";
  }
  if (str == "04004") {
    workTypeStr = "维修•电器";
  }
  if (str == "04005") {
    workTypeStr = "维修•钣金";
  }
  if (str == "04006") {
    workTypeStr = "维修•涂漆";
  }
  if (str == "04007") {
    workTypeStr = "维修•技术评估";
  }
  if (str == "05001") {
    workTypeStr = "理论教练员";
  }
  if (str == "05002") {
    workTypeStr = "操作教练员";
  }
  if (str == "05003") {
    workTypeStr = "客货教练员";
  }
  if (str == "05005") {
    workTypeStr = "危货教练员";
  }
  if (str == "05006") {
    workTypeStr = "放射品教练员";
  }
  if (str == "05007") {
    workTypeStr = "残疾人教练员";
  }
  if (str == "09001") {
    workTypeStr = "出租车驾驶员";
  }
  if (str == "11001") {
    workTypeStr = "客运经理人";
  }
  if (str == "11002") {
    workTypeStr = "货运经理人";
  }
  if (str == "11003") {
    workTypeStr = "维修经理人";
  }
  if (str == "11004") {
    workTypeStr = "驾培经理人";
  }
  if (str == "12001") {
    workTypeStr = "租赁业务员";
  }
  if (str == "12002") {
    workTypeStr = "客运乘务员";
  }
  if (str == "12008") {
    workTypeStr = "驾培负责人";
  }
  if (str == "12009") {
    workTypeStr = "驾培考核员";
  }
  if (str == "12010") {
    workTypeStr = "维修结算员";
  }
  if (str == "12011") {
    workTypeStr = "维修接待员";
  }
  if (str == "13001") {
    workTypeStr = "公交驾驶员";
  }
  if (str == "14001") {
    workTypeStr = "轨道驾驶员";
  }
  if (str == "14002") {
    workTypeStr = "轨道调度员";
  }
  if (str == "14003") {
    workTypeStr = "轨道值班员";
  }
  return workTypeStr;
}

/*************从业状态***************/
function getPracState(str) {
  if (str == 1) {
    str = "从业";
  }
  if (str == 2) {
    str = "待业";
  }
  if (str == 9) {
    str = "注销";
  }
  if (str == 10) {
    str = "吊销";
  }
  if (str == 11) {
    str = "撤销";
  }
  return str;
}

/*************人员来源***************/
function getPracSource(str) {
  if (str == 0) {
    str = "本籍从业人员";
  }
  if (str == 1) {
    str = "外籍从业人员";
  }
  if (str == 2) {
    str = "非从业人员";
  }
  return str;
}

/*************人员状态***************/
function getPracStatus(str) {
  if (str == 1) {
    str = "正常";
  }
  if (str == 2) {
    str = "任务中";
  }
  return str;
}

/*************性别***************/
function getSex(str) {
  if (str == 1) {
    str = "男";
  }
  if (str == 2) {
    str = "女";
  }
  return str;
}

/*************诚信考核/继续教育状态***************/
function getCreditStatus(str) {
  if (str == 0) {
    str = "进行中";
  }
  if (str == 1) {
    str = "已完成";
  }
  if (str == 2) {
    str = "未完成";
  }
  if (str == 9) {
    str = "无效";
  }
  return str;
}

/*************诚信考核等级***************/
function getCreditLevel(str) {
  if (str == 0) {
    str = "未考核";
  }
  if (str == 1) {
    str = "优良(AAA级)";
  }
  if (str == 2) {
    str = "合格(AA级)";
  }
  if (str == 3) {
    str = "基本合格(A级)";
  }
  if (str == 4) {
    str = "不合格(B级)";
  }
  return str;
}

/*************车辆技术等级***************/
function vehiTechnologyLevel(str) {
  if (str == 0) {
    str = "未评定";
  }
  if (str == 1) {
    str = "一级";
  }
  if (str == 2) {
    str = "二级";
  }
  if (str == 3) {
    str = "三级";
  }
  if (str == 9) {
    str = "未达标";
  }
  return str;
}

/*************车辆技术等级评定状态***************/
function vehiInspectState(str) {
  if (str == 0) {
    str = "未评定";
  }
  if (str == 1) {
    str = "已评定";
  }
  if (str == 2) {
    str = "历史";
  }
  if (str == 9) {
    str = "无效";
  }
  return str;
}

/*************车辆审验状态***************/
function vehiTechnologyState(str) {
  if (str == 0) {
    str = "未审验";
  }
  if (str == 1) {
    str = "进行中";
  }
  if (str == 2) {
    str = "已审验";
  }
  if (str == 9) {
    str = "无效";
  }
  return str;
}

/*************车辆审验结果***************/
function vehiTechnologyres(str) {
  if (str == 1) {
    str = "合格";
  }
  if (str == 2) {
    str = "不合格";
  }
  if (str == 3) {
    str = "已审验";
  }
  if (str == 9) {
    str = "无效";
  }
  return str;
}

/*************身份证件类别***************/
function changeCertType(str) {
  if (str == 1) {
    str = "身份证";
  }
  if (str == 2) {
    str = "军官证";
  }
  if (str == 3) {
    str = "警官证";
  }
  if (str == 4) {
    str = "外国护照";
  }
  if (str == 5) {
    str = "港澳台居民证";
  }
  if (str == 9) {
    str = "其他";
  }
  return str;
}

/*************身份证件类别***************/
function changeLisenseType(str) {
  if (str == 1) {
    str = "身份证";
  }
  if (str == 2) {
    str = "驾驶证";
  }
  if (str == 3) {
    str = "从业资格证";
  }
  if (str == 9) {
    str = "其他证件";
  }
  return str;
}

/*************学历***************/
function getEducation(str) {
  if (str == 10) {
    str = "研究生";
  }
  if (str == 20) {
    str = "本科";
  }
  if (str == 30) {
    str = "大专";
  }
  if (str == 40) {
    str = "中专技校";
  }
  if (str == 60) {
    str = "高中";
  }
  if (str == 70) {
    str = "初中";
  }
  if (str == 80) {
    str = "小学";
  }
  if (str == 90) {
    str = "其他";
  }
  return str;
}

/*************检测管理 检测类别***************/
function changeDetectType(str) {
  if (str == 1) {
    str = "等级评定";
  }
  if (str == 2) {
    str = "春运检测";
  }
  return str;
}

/*************检测管理 检测站企业性质***************/
function changeDsType(str) {
  if (str == 1) {
    str = "国有企业";
  }
  if (str == 2) {
    str = "民营企业";
  }
  if (str == 3) {
    str = "有限公司";
  }
  if (str == 4) {
    str = "有限责任公司";
  }
  if (str == 5) {
    str = "股份有限公司";
  }
  if (str == 6) {
    str = "集体";
  }
  if (str == 7) {
    str = "其他";
  }
  return str;
}

/*************证据类型***************/
function getEvidenceType(str) {
  if (str == 1) {
    str = "书证";
  }
  if (str == 2) {
    str = "物证";
  }
  if (str == 3) {
    str = "视听材料";
  }
  if (str == 4) {
    str = "当事人陈述";
  }
  if (str == 5) {
    str = "证人证言";
  }
  if (str == 6) {
    str = "现场笔录";
  }
  if (str == 7) {
    str = "电子数据";
  }
  if (str == 9) {
    str = "其他";
  }
  return str;
}
/*************字符串截取***************/
function subStr(str) {
  if (str == null) {
    return "";
  }
  if (str.length < 10) {
    return str;
  }
  return str.substr(0, 9) + "...";
}

/*************日期截取年月日，去除时分秒***************/
function subymd(datetime) {
  return datetime.substr(0, 10);
}

/*************经济类型***************/
function changeEconomicType(str) {
  if (str == "100") {
    str = "内资";
  }
  if (str == "110") {
    str = "国有全资";
  }
  if (str == "120") {
    str = "集体全资";
  }
  if (str == "130") {
    str = "股份合作";
  }
  if (str == "140") {
    str = "联营";
  }
  if (str == "141") {
    str = "国有联营";
  }
  if (str == "142") {
    str = "集体联营";
  }
  if (str == "143") {
    str = "国有与集体联营";
  }
  if (str == "149") {
    str = "其他联营";
  }
  if (str == "150") {
    str = "有限责任（公司）";
  }
  if (str == "151") {
    str = "国有独资（公司）";
  }
  if (str == "159") {
    str = "其他有限责任（公司）";
  }
  if (str == "160") {
    str = "股份有限（公司）";
  }
  if (str == "170") {
    str = "私有";
  }
  if (str == "171") {
    str = "私有独资";
  }
  if (str == "172") {
    str = "私有合伙";
  }
  if (str == "173") {
    str = "私营有限责任(公司)";
  }
  if (str == "174") {
    str = "私营股份有限(公司)";
  }
  if (str == "175") {
    str = "个体经营";
  }
  if (str == "179") {
    str = "其他私有";
  }
  if (str == "190") {
    str = "其他内资";
  }
  if (str == "200") {
    str = "港、澳、台投资";
  }
  if (str == "210") {
    str = "内地和港、澳、台合资";
  }
  if (str == "220") {
    str = "内地和港、澳、台合作";
  }
  if (str == "230") {
    str = "港、澳、台独资";
  }
  if (str == "240") {
    str = "港、澳、台投资股份有限(公司)";
  }
  if (str == "290") {
    str = "其他港、澳、台投资";
  }
  if (str == "300") {
    str = "国外投资";
  }
  if (str == "310") {
    str = "中外合资";
  }
  if (str == "320") {
    str = "中外合作";
  }
  if (str == "330") {
    str = "外资";
  }
  if (str == "340") {
    str = "国外投资股份有限(公司)";
  }
  if (str == "390") {
    str = "其他国外投资";
  }
  if (str == "900") {
    str = "其他";
  }
  return str;
}

/*************民族***************/
function getNationality(str) {
  switch (str) {
    case "01":
      return "汉族";
    case "02":
      return "蒙古族";
    case "03":
      return "回族";
    case "04":
      return "藏族";
    case "05":
      return "维吾尔族";
    case "06":
      return "苗族";
    case "07":
      return "彝族";
    case "08":
      return "壮族";
    case "09":
      return "布依族";
    case "10":
      return "朝鲜族";
    case "11":
      return "满族";
    case "12":
      return "侗族";
    case "13":
      return "瑶族";
    case "14":
      return "白族";
    case "15":
      return "土家族";
    case "16":
      return "哈尼族";
    case "17":
      return "哈萨克族";
    case "18":
      return "傣族";
    case "19":
      return "黎族";
    case "20":
      return "僳僳族";
    case "21":
      return "佤族";
    case "22":
      return "畲族";
    case "23":
      return "高山族";
    case "24":
      return "拉祜族";
    case "25":
      return "水族";
    case "26":
      return "东乡族";
    case "27":
      return "纳西族";
    case "28":
      return "景颇族";
    case "29":
      return "柯尔克孜族";
    case "30":
      return "土族";
    case "31":
      return "达翰尔族";
    case "32":
      return "仫佬族";
    case "33":
      return "羌族";
    case "34":
      return "布朗族";
    case "35":
      return "撒拉族";
    case "36":
      return "毛南族";
    case "37":
      return "仡佬族";
    case "38":
      return "锡伯族";
    case "39":
      return "阿昌族";
    case "40":
      return "普米族";
    case "41":
      return "塔吉克族";
    case "42":
      return "怒族";
    case "43":
      return "乌孜别克族";
    case "44":
      return "俄罗斯族";
    case "45":
      return "鄂温克族";
    case "46":
      return "德昂族";
    case "47":
      return "保安族";
    case "48":
      return "裕固族";
    case "49":
      return "京族";
    case "50":
      return "塔塔尔族";
    case "51":
      return "独龙族";
    case "52":
      return "鄂伦春族";
    case "53":
      return "郝哲族";
    case "54":
      return "门巴族";
    case "55":
      return "珞巴族";
    case "56":
      return "基诺族";
    case "97":
      return "其他";
    case "98":
      return "外国血统中国籍人士";
    default:
      return "";
  }
}

/*************包车标志牌业务类型转换***************/
function getApplyTypeName(applyType) {
  var applyTypeName = "";
  if (applyType == 0) {
    applyTypeName = "旅游";
  }
  if (applyType == 1) {
    applyTypeName = "非旅游";
  }
  return applyTypeName;
}

/*************包车标志牌记录状态转换***************/
function getRecordStateName(recordState) {
  var recordStateName = "";
  if (recordState == 1) {
    recordStateName = "已提交";
  }
  if (recordState == 2) {
    recordStateName = "已生效";
  }
  if (recordState == 3) {
    recordStateName = "已完成";
  }
  if (recordState == 4) {
    recordStateName = "已撤销";
  }
  if (recordState == 5) {
    recordStateName = "已作废";
  }
  return recordStateName;
}

/*************包车标志牌审批状态转换***************/
function getApprovalStateName(approvalState) {
  var approvalStateName = "";
  if (approvalState == 1) {
    approvalStateName = "待审批";
  }
  if (approvalState == 2) {
    approvalStateName = "通过";
  }
  if (approvalState == 3) {
    approvalStateName = "不通过";
  }
  return approvalStateName;
}

/*************包车标志牌经营范围转换***************/
function getSignsTypeName(signsType) {
  var signsTypeName = "";
  if (signsType == "01204") {
    signsTypeName = "省际包车";
  }
  if (signsType == "01203") {
    signsTypeName = "市际包车";
  }
  if (signsType == "01202") {
    signsTypeName = "县际包车";
  }
  return signsTypeName;
}
/************* 0，2 否 1 是***************/
function getWhetherOrNot(str) {
  var strName = "";
  if (str == 0) {
    strName = "否";
  }
  if (str == 1) {
    strName = "是";
  }
  if (str == 2) {
    strName = "否";
  }
  return strName;
}
/************* 获取gps比对结果***************/
function getGPSResult(GPSResult) {
  var GPSResultStr = "";
  if (GPSResult == 0) {
    GPSResultStr = "GPS比对未进行";
  }
  if (GPSResult == 1) {
    GPSResultStr = "GPS比对合格";
  }
  if (GPSResult == 2) {
    GPSResultStr = "GPS比对不合格";
  }
  if (GPSResult == 3) {
    GPSResultStr = "GPS比对失败";
  }
  if (GPSResult == 4) {
    GPSResultStr = "获取数据异常";
  }
  return GPSResultStr;
}

/*
 *将一个对象解析为JSON字符串，然后返回这个字符串
 *
 * Object：要解析的对象
 * max：(可选)
 *
 */
function toJSON(object, max) {
  if (max == null) max = Number.POSITIVE_INFINITY;
  var f = function (obj, num) {
    if (typeof obj == "string") return '"' + obj + '"';
    if (typeof obj == "number") return obj + "";
    if (typeof obj == "boolean") return obj + "";
    if (typeof obj == "function") return "function";
    if (typeof obj == "undefined") return "undefined";
    if (obj == null) return "null";
    if (num > max) {
      if (Array.isArray(obj)) return "array";
      return "object";
    }
    var s1 = "",
      s2 = "";
    for (var i = 1; i < num; i++) s1 = s1 + "\t";
    s2 = s1 + "\t";
    var str = "";

    if (Array.isArray(obj)) {
      str = "[";
      for (var key in obj) str = str + "\n" + s2 + f(obj[key], num + 1) + ",";
      str = str.substring(0, str.length - 1) + "\n" + s1 + "]";
    } else {
      str = "{";
      for (var key in obj)
        str = str + "\n" + s2 + key + ":" + f(obj[key], num + 1) + ",";
      str = str.substring(0, str.length - 1) + "\n" + s1 + "}";
    }
    return str;
  };
  return f(object, 1);
}

/*
 * 弹出一个消息框
 * */
function showMsg({
  title = "提示", //标题
  content, //内容
  buttonContent = "确认", //按钮内容
  clickClose = false, //点击背景时，是否关闭弹窗
}) {
  var html = `
        <div style="width:100%;height: 100%;position: absolute;background-color: rgba(0,0,0,0.5);font-size: 16px;color:#808080;top:0px;left:0px;" class="__showMsg">
            <div style="width:calc(100% - 60px);position: absolute;background-color: #FFFFFF;left:30px;top:50%;transform: translateY(-50%);">
                <div style="margin:15px 0 15px 15px;width:calc(100% - 30px);color:#87CEFA;font-size: 22px;">${title}</div>
                <div style="margin-left:10px;width:calc(100% - 20px);border-top:solid 1px #CCCCCC;"></div>
                <div style="margin:15px 0 35px 15px;width:calc(100% - 30px)">${content}</div>
                <div style="margin:15px 0 15px 15px;width:calc(100% - 32px);text-align: center;line-height: 40px;height:40px;border: solid 1px #CCCCCC;">${buttonContent}</div>
            </div>
        </div>
    `;

  console.log(html);

  var close = function (event) {
    event.stopPropagation();
    var body = document.querySelector("body");
    var msgEle = document.querySelector(".__showMsg");
    body.removeChild(msgEle);
  };

  var body = document.querySelector("body");
  body.innerHTML = body.innerHTML + html;

  document.querySelector(".__showMsg>div>div:nth-child(4)").onclick = close;
  document.querySelector(".__showMsg>div").onclick = function (event) {
    event.stopPropagation();
  };
  if (clickClose) {
    document.querySelector(".__showMsg").onclick = close;
  }
}

//弹出一个列表
function showList({
  list = [], //一个数组，元素必须是个html字符串
  onclick, //function(event,index){}
}) {
  var html = `
        <div style="width:100%;height: 110%;position: absolute;background-color: rgba(0,0,0,0.5);font-size: 16px;color:#808080;top:0px;left:0px;" class="__showList">
            <ul style="width:calc(100%);position: absolute;top:50%;transform: translateY(-50%);list-style-type: none;">
                ${list
                  .map((value, index) => {
                    return `<li style="position: relative;width:100%;" index="${index}"> ${value}</li>`;
                  })
                  .toString()
                  .replace(/,/g, "")}
            </ul>
        </div>
    `;

  var body = document.querySelector("body");
  body.innerHTML = body.innerHTML + html;

  if (typeof onclick === "function") {
    document.querySelector(".__showList>ul").onclick = function (event) {
      event.stopPropagation();
      var ele = event.target;
      while (ele != null && ele.tagName !== "LI") {
        ele = ele.parentElement;
      }
      if (ele == null || ele.tagName !== "LI") {
        return;
      }
      onclick(event, ele.getAttribute("index"));
    };
  }

  var close = function (event) {
    if (event && event.stopPropagation) {
      event.stopPropagation();
    }
    var body = document.querySelector("body");
    var msgEle = document.querySelector(".__showList");
    body.removeChild(msgEle);
  };
  document.querySelector(".__showList").onclick = close;
  return close;
}

//获得元素的绝对位置
function getLocationBySelector(str) {
  var ele = document.querySelector(str);
  if (ele == null) return null;
  var body = document.querySelector("body");
  var result = {
    left: 0,
    top: 0,
    width: ele.offsetWidth,
    height: ele.offsetHeight,
  };
  while (ele !== body) {
    result.left += ele.offsetLeft;
    result.top += ele.offsetTop;
    ele = ele.parentElement;
  }
  return result;
}

//获取当前时间 格式yyyy-MM-dd hh:mm:ss
function curentTime() {
  var now = new Date();
  var year = now.getFullYear(); //年
  var month = now.getMonth() + 1; //月
  var day = now.getDate(); //日
  var hh = now.getHours(); //时
  var mm = now.getMinutes(); //分
  var ss = now.getSeconds(); //秒
  var clock = year + "-";
  if (month < 10) clock += "0";
  clock += month + "-";
  if (day < 10) clock += "0";
  clock += day + " ";
  if (hh < 10) clock += "0";
  clock += hh + ":";
  if (mm < 10) clock += "0";
  clock += mm + ":";
  if (ss < 10) clock += "0";
  clock += ss;
  return clock;
}

/*****************获取日期*******************/
function getCaseDate(type) {
  var now = new Date();
  var year;
  if (type == 0) {
    year = now.getFullYear() - 1;
  } else {
    year = now.getFullYear();
  }
  var month = now.getMonth() + 1;
  if (month < 10) {
    month = "0" + month;
  }
  var day = now.getDate();
  if (day < 10) {
    day = "0" + day;
  }

  return year + "-" + month + "-" + day;
}

//获取当前时间 格式yyyyMMdd_hhmmss
function getFileName() {
  var now = new Date();
  var year = now.getFullYear(); //年
  var month = now.getMonth() + 1; //月
  var day = now.getDate(); //日
  var hh = now.getHours(); //时
  var mm = now.getMinutes(); //分
  var ss = now.getSeconds(); //秒
  var clock = year;
  if (month < 10) clock += "0";
  clock += month;
  if (day < 10) clock += "0";
  clock += day + "_";
  if (hh < 10) clock += "0";
  clock += hh;
  if (mm < 10) clock += "0";
  clock += mm;
  if (ss < 10) clock += "0";
  clock += ss;
  return clock;
}

/*****************检测等级*******************/
function getCaseSource(str) {
  if (str == null || str == "") return "";
  if (str == "执法检查发现") return "1";
  if (str == "群众举报") return "2";
  if (str == "电话投诉") return "3";
  if (str == "上级机关交办") return "4";
  if (str == "有关部门移送") return "5";
  if (str == "媒体曝光") return "6";
  if (str == "其他") return "9";

  if (str == "1") return "执法检查发现";
  if (str == "2") return "群众举报";
  if (str == "3") return "电话投诉";
  if (str == "4") return "上级机关交办";
  if (str == "5") return "有关部门移送";
  if (str == "6") return "媒体曝光";
  if (str == "9") return "其他";
  return "";
}

/*********客车等级代码转化为等级内容*************/
function convertCoachLevel(str) {
  if (str == "11") return "特大型高三级";
  if (str == "12") return "特大型高二级";
  if (str == "13") return "特大型高一级";
  if (str == "14") return "特大型中级";
  if (str == "15") return "特大型普通级";
  if (str == "21") return "大型高三级";
  if (str == "22") return "大型高二级";
  if (str == "23") return "大型高一级";
  if (str == "24") return "大型中级";
  if (str == "25") return "大型普通级";
  if (str == "31") return "中型高二级";
  if (str == "32") return "中型高一级";
  if (str == "33") return "中型中级";
  if (str == "34") return "中型普通级";
  if (str == "41") return "小型高二级";
  if (str == "42") return "小型高一级";
  if (str == "43") return "小型中级";
  if (str == "44") return "小型普通级";
  if (str == "51") return "乘用车高二级";
  if (str == "52") return "乘用车高一级";
  if (str == "53") return "乘用车中级";
  if (str == "54") return "乘用车普通级";
  if (str == "0") return "未评定";
  return "";
}

function changeRpholidayState(str) {
  if (str == "3") return "归档";
  if (str == "2") return "省";
  if (str == "1") return "市";
  if (str == "0") return "区县";
  return "";
}

/****************生成uuid******************/
function uuid(len, radix) {
  var chars = "0123456789abcdefghijklmnopqrstuvwxyz".split("");
  var uuid = [],
    i;
  radix = radix || chars.length;
  if (len) {
    for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)];
  } else {
    var r;
    uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-";
    uuid[14] = "4";
    for (i = 0; i < 36; i++) {
      if (!uuid[i]) {
        r = 0 | (Math.random() * 16);
        uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r];
      }
    }
  }
  return uuid.join("");
}

/****************图片大小单位转换******************/
function fmtFileSize(bsize) {
  var size;
  if (bsize >= 1024 * 1024 * 1024) {
    size = (bsize / (1024 * 1024 * 1024)).toFixed(2) + "GB";
  } else if (bsize >= 1024 * 1024) {
    size = (bsize / (1024 * 1024)).toFixed(2) + "MB";
  } else if (bsize >= 1024) {
    size = (bsize / 1024).toFixed(2) + "KB";
  } else if (bsize < 1024) {
    if (bsize <= 0) {
      size = "0B";
    } else {
      size = bsize + "B";
    }
  }
  return size;
}

/****************时间格式转换******************/
Date.prototype.format = function (format) {
  var date = {
    "M+": this.getMonth() + 1,
    "d+": this.getDate(),
    "h+": this.getHours(),
    "m+": this.getMinutes(),
    "s+": this.getSeconds(),
    "q+": Math.floor((this.getMonth() + 3) / 3),
    "S+": this.getMilliseconds(),
  };
  if (/(y+)/i.test(format)) {
    format = format.replace(
      RegExp.$1,
      (this.getFullYear() + "").substr(4 - RegExp.$1.length)
    );
  }
  for (var k in date) {
    if (new RegExp("(" + k + ")").test(format)) {
      format = format.replace(
        RegExp.$1,
        RegExp.$1.length == 1
          ? date[k]
          : ("00" + date[k]).substr(("" + date[k]).length)
      );
    }
  }
  return format;
};

function checkVecle(s) {
  var regu = (reg =
    /^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DABCEFGHJK]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/);

  // var regu = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-HJ-NP-Z]{1}[0-9A-HJ-NP-Z]{5,6}$/;
  // var regu = /^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[a-zA-Z](([DF]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[DF]))|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})$/;
  var re = new RegExp(regu);
  if (re.test(s)) {
    return true;
  } else {
    return false;
  }
}

function topBack() {
  api.closeFrame(api.frameName);
}

// 在文件末尾添加以下导出语句
export {
  analysisMyValue,
  changeVehicleLocus,
  pronameChangecode,
  procodeChangename,
  pronameChangeVehi,
  vehiChangeProname,
  changeOperstate,
  changeOperowner,
  changePlatecolor,
  changePlatecolorCode,
  changeTrans,
  changeVehType,
  getFueltype,
  lockmode,
  isEntry,
  vehiuse,
  certstype,
  certstatus,
  ownercerttype,
  getPracCertType,
  getPracPersonnelType,
  getWorkType,
  getPracState,
  getPracSource,
  getPracStatus,
  getSex,
  getCreditStatus,
  getCreditLevel,
  vehiTechnologyLevel,
  vehiInspectState,
  vehiTechnologyState,
  vehiTechnologyres,
  changeCertType,
  changeLisenseType,
  getEducation,
  changeDetectType,
  changeDsType,
  getEvidenceType,
  subStr,
  subymd,
  changeEconomicType,
  getNationality,
  getApplyTypeName,
  getRecordStateName,
  getApprovalStateName,
  getSignsTypeName,
  getWhetherOrNot,
  getGPSResult,
  toJSON,
  showMsg,
  showList,
  getLocationBySelector,
  curentTime,
  getCaseDate,
  getFileName,
  getCaseSource,
  convertCoachLevel,
  changeRpholidayState,
  uuid,
  fmtFileSize,
  checkVecle,
  topBack,
};
